package api

import (
	. "gin-chat/controller"
	. "gin-chat/router/middleware"
	"github.com/gin-gonic/gin"
)

//定义路由
func RouteInit() *gin.Engine {
	route := gin.New()
	route.Use(Cors())
	route.Use(gin.Logger(), gin.Recovery())
	route.Use(EnableCookieSession())

	route.POST("register", Register)
	route.POST("login", Login)

	chat := route.Group("/")
	chat.Use(AuthSessionMiddle())
	{
		chat.GET("chat", Init)
		chat.GET("friends", Friends)
		chat.POST("user/info", UserInfo)
		chat.POST("chat/record", ChatRecordPage)
	}
	route.GET("test", Login)
	return route
}
